# @Filename:    sample1
# @Author:      王佳伟
# @Time:        2025-02-25 16:56
# @Describe:    邮件发送报告
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText


def send_email(sender, password, receiver, subject, message):
    smtp_server = 'smtp.example.com'
    smtp_port = 587
    msg = MIMEMultipart()
    msg['From'] = sender
    msg['To'] = receiver
    msg['Subject'] = subject
    msg.attach(MIMEText(message, 'plain'))
    with smtplib.SMTP(smtp_server, smtp_port) as server:
        server.starttls()
        server.login(sender, password)
        server.send_message(msg)


if __name__ == '__main__':
    sender = 'sender@example.com'
    password = 'password'
    receiver = 'receiver@example.com'
    subject = '自动化测试报告'
    message = '这是自动化测试的报告，请查收'
    send_email(sender, password, receiver, subject, message)
